import {
  generateHighlightNodeForSalePrice
} from '@/utils/bizUtils';
const formatWayToCargo = (val) => {
  if (!val && val != 0) {
    return '';
  }
  if (val == 0) {
    return '自进货';
  }
  if (val == 1) {
    return '内部调货';
  }
  return val;
}
// 格式化下架处理方式
const formatUpDownProcessingModel = (val) => {
  if (!val) {
    return '';
  }
  if (val == 1) {
    return '转货';
  } else if (val == 2) {
    return '退货';
  } else if (val == 3) {
    return '报废';
  }
  return '';
}
// 格式化上下限调整类型
const formatAdjustType = (val) => {
  if (!val) {
    return '';
  }
  if (val == 1) {
    return '日常调整';
  } else if (val == 2) {
    return '上下限调0';
  } else if (val == 3) {
    return '新作库存';
  }
  return '';
}
// 要货方式
const STATE_OPTIONS = [
  {
    label: '自进货',
    value: '0'
  },
  {
    label: '内部调货',
    value: '1'
  },
]

// 初始化查询条件
export const initFormItemList = (areaData, brandData, companyData, centerData) => {
  return [
    {
      prop: 'categoryUuids',
      label: '分类名称',
      type: 'category'
    },
    {
      prop: 'skuNo',
      label: 'SKU编码',
      type: 'input'
    },
    {
      prop: 'productName',
      label: '商品名称',
      type: 'input'
    },
    {
      prop: 'brandUuid',
      label: '品牌',
      type: 'selectFilter',
      filterable: true,
      clearable: true,
      allOptions: brandData || [],
      options: [],
    },
    {
      prop: 'companyId',
      label: '公司名称',
      type: 'selectFilter',
      filterable: true,
      clearable: true,
      allOptions: companyData || [],
      options: [],
    },
    {
      prop: 'saleAreaNo',
      label: '业务区域',
      type: 'select',
      filterable: true,
      clearable: true,
      options: areaData || [],
    },
    {
      prop: 'upperLimit',
      label: '上限',
      type: 'range',
      rangeType: 'inputNum',
      precision: 3,
      props: ['upperLimitFrom', 'upperLimitTo']
    },
    {
      prop: 'wayToCargo',
      label: '要货方式',
      type: 'select',
      options: STATE_OPTIONS
    },
    {
      prop: 'centerDepartments',
      label: '归属中心',
      type: 'select',
      multiple: true,
      options: centerData
    },
    {
      prop: 'lowerLimit',
      label: '下限',
      type: 'range',
      rangeType: 'inputNum',
      precision: 3,
      props: ['lowerLimitFrom', 'lowerLimitTo']
    },
  ]
}
// 上下限主页表头
export const TABALE_COLUMNS = [
  {
    title: '品类树',
    key: 'categoryPath',
  },
  {
    title: '四级类代码',
    key: 'categoryNo',
  },
  /* {
    title: '公司ID',
    key: 'companyId',
  }, */
  {
    title: '公司名称',
    key: 'companyName',
  },
  {
    title: '商品代码',
    key: 'skuNo',
  },
  {
    title: '商品名称',
    key: 'productName',
  },
  {
    title: '件装数量',
    key: 'pieceInfo',
  },
  {
    title: '规格型号',
    key: 'specModel'
  },
  {
    title: '计量单位',
    key: 'unitName'
  },
  {
    title: '品牌',
    key: 'brandName',
  },
  {
    title: '要货方式',
    key: 'wayToCargoName',
  },
  {
    title: '下限',
    key: 'lowerLimit'
  },
  {
    title: '上限',
    key: 'upperLimit'
  },
  {
    title: '虚拟比例',
    key: 'virtualProportion'
  },
  {
    title: '下架处理方式',
    key: 'upDownProcessingModelName',
  },
  {
    title: '商品归属中心',
    key: 'belongToCenter',
  },
  {
    title: '存量溢出属性',
    key: 'stockOutAttrStr',
  },
  {
    title: '预计消化区间',
    key: 'planDigestionRegionStr',
  },
  {
    title: '是否季节性商品',
    key: 'isSeasonStr',
  },
  {
    title: '上架期',
    key: 'putOnPeriod',
  },
  {
    title: '下架期',
    key: 'putOffPeriod',
  },
  {
    title: '存量属性',
    key: 'stockAttrStr',
  },
  {
    title: '新做库存日期',
    key: 'limitNotZeroTime',
  },
  {
    title: '近90天销量',
    key: 'threeMonthsOutbound',
  },
  {
    title: '往年未来90天销量',
    key: 'sameTermOutbound',
  },
  {
    title: '近一年销量',
    key: 'yearlyOutbound',
  },
  {
    title: '商品到货周期',
    key: 'arrivalPeriod',
  },
  {
    title: '实物库存',
    key: 'productStock',
  },
  {
    title: '仓位',
    key: 'stockName',
  },
  {
    title: '更新人',
    key: 'lastModifiedName',
  },
  {
    title: '更新时间',
    key: 'lastModifiedTime',
  }
]

// 批量导入表头
export const EDIT_TABLE_COLUMNS = [
  /* {
    title: '公司ID',
    key: 'companyId',
  }, */
  {
    title: '公司名称',
    key: 'companyName',
  },
  {
    title: 'SKU编码',
    key: 'skuNo',
  },
  {
    title: '商品名称',
    key: 'productName',
  },
  {
    title: '规格',
    key: 'specDetail',
  },
  {
    title: '主计量单位',
    key: 'unitName',
  },
  {
    title: '下限-原值',
    key: 'oldLowerLimit',
  },
  {
    title: '下限-现值',
    key: 'lowerLimit',
  },
  {
    title: '上限-原值',
    key: 'oldUpperLimit',
  },
  {
    title: '上限-现值',
    key: 'upperLimit',
  },
  {
    title: '要货方式-原值',
    key: 'oldWayToCargo',
    formatter: (row, columns, cellValue) => {
      return formatWayToCargo(cellValue);
    },
  },
  {
    title: '要货方式-现值',
    key: 'wayToCargo',
    formatter: (row, columns, cellValue) => {
      return formatWayToCargo(cellValue);
    },
  },
  {
    title: '虚拟比例-原值',
    key: 'oldVirtualProportion',
  },
  {
    title: '虚拟比例-现值',
    key: 'virtualProportion',
  },
  {
    title: '下架处理方式-原值',
    key: 'oldUpDownProcessingModel',
    width: 130,
    formatter: (row, columns, cellValue) => {
      return formatUpDownProcessingModel(cellValue)
    }
  },
  {
    title: '下架处理方式-现值',
    key: 'upDownProcessingModel',
    width: 130,
    formatter: (row, columns, cellValue) => {
      return formatUpDownProcessingModel(cellValue)
    }
  },
  {
    title: '上下限调整类型',
    key: 'adjustType',
    formatter: (row, columns, cellValue) => {
      return formatAdjustType(cellValue)
    }
  },
  {
    title: '归属部门的上级部门',
    key: 'authDepartment',
  },
  {
    title: '存量溢出属性',
    key: 'stockOutAttrStr',
  },
  {
    title: '预计消化区间',
    key: 'planDigestionRegionStr',
  },
  {
    title: '是否季节性商品',
    key: 'isSeasonStr',
  },
  {
    title: '上架期',
    key: 'putOnPeriod',
  },
  {
    title: '下架期',
    key: 'putOffPeriod',
  },
  {
    title: '存量属性',
    key: 'stockAttrStr',
  },
  {
    title: '新做库存日期',
    key: 'limitNotZeroTime',
  },
  {
    title: '近90天销量',
    key: 'threeMonthsOutbound',
  },
  {
    title: '往年未来90天销量',
    key: 'sameTermOutbound',
  },
  {
    title: '近一年销量',
    key: 'yearlyOutbound',
  },
  {
    title: '商品到货周期',
    key: 'arrivalPeriod',
  },
  {
    title: '实物库存',
    key: 'productStock',
  },
  {
    title: '仓位',
    key: 'stockName',
  },
]

// 批量导入查看表头
export const VIEW_TABLE_COLUMNS = [
  /* {
    title: '公司ID',
    key: 'companyId',
  }, */
  {
    title: '公司名称',
    key: 'companyName',
  },
  {
    title: 'SKU编码',
    key: 'skuNo',
  },
  {
    title: '商品名称',
    key: 'productName',
  },
  {
    title: '规格',
    key: 'specDetail',
  },
  {
    title: '主计量单位',
    key: 'unitName',
  },
  {
    title: '下限-原值',
    key: 'oldLowerLimit',
  },
  {
    title: '下限-现值',
    key: 'lowerLimit',
    render: (h, { row }) => {
      return generateHighlightNodeForSalePrice(h, row.oldLowerLimit, row.lowerLimit)
    }
  },
  {
    title: '上限-原值',
    key: 'oldUpperLimit',
  },
  {
    title: '上限-现值',
    key: 'upperLimit',
    render: (h, { row }) => {
      return generateHighlightNodeForSalePrice(h, row.oldUpperLimit, row.upperLimit)
    }
  },
  {
    title: '要货方式-原值',
    key: 'oldWayToCargo',
    formatter: (row, columns, cellValue) => {
      return formatWayToCargo(cellValue);
    },
  },
  {
    title: '要货方式-现值',
    key: 'wayToCargo',
    render: (h, { row }) => {
      return generateHighlightNodeForSalePrice(h, row.oldWayToCargo, row.wayToCargo, formatWayToCargo(row.wayToCargo))
    }
  },
  {
    title: '虚拟比例-原值',
    key: 'oldVirtualProportion',
  },
  {
    title: '虚拟比例-现值',
    key: 'virtualProportion',
    render: (h, { row }) => {
      return generateHighlightNodeForSalePrice(h, row.oldVirtualProportion, row.virtualProportion)
    }
  },
  {
    title: '下架处理方式-原值',
    key: 'oldUpDownProcessingModel',
    width: 130,
    formatter: (row, columns, cellValue) => {
      return formatUpDownProcessingModel(cellValue)
    }
  },
  {
    title: '下架处理方式-现值',
    key: 'upDownProcessingModel',
    width: 130,
    render: (h, { row }) => {
      return generateHighlightNodeForSalePrice(h, row.oldUpDownProcessingModel, row.upDownProcessingModel, formatUpDownProcessingModel(row.upDownProcessingModel))
    }
  },
  {
    title: '上下限调整类型',
    key: 'adjustType',
    formatter: (row, columns, cellValue) => {
      return formatAdjustType(cellValue)
    }
  },
  {
    title: '归属部门的上级部门',
    key: 'authDepartment',
  },
  {
    title: '存量溢出属性',
    key: 'stockOutAttrStr',
  },
  {
    title: '预计消化区间',
    key: 'planDigestionRegionStr',
  },
  {
    title: '是否季节性商品',
    key: 'isSeasonStr',
  },
  {
    title: '上架期',
    key: 'putOnPeriod',
  },
  {
    title: '下架期',
    key: 'putOffPeriod',
  },
  {
    title: '存量属性',
    key: 'stockAttrStr',
  },
  {
    title: '新做库存日期',
    key: 'limitNotZeroTime',
  },
  {
    title: '近90天销量',
    key: 'threeMonthsOutbound',
  },
  {
    title: '往年未来90天销量',
    key: 'sameTermOutbound',
  },
  {
    title: '近一年销量',
    key: 'yearlyOutbound',
  },
  {
    title: '商品到货周期',
    key: 'arrivalPeriod',
  },
  {
    title: '实物库存',
    key: 'productStock',
  },
  {
    title: '仓位',
    key: 'stockName',
  },
]

export const PARAMS_TYPES = {
  formSearch: Symbol('formSearch'), // 表单查询
  seniorSearch: Symbol('seniorSearch'), // 高级关联
  formExport: Symbol('formExport'), // 表单导出
  seniorExport: Symbol('seniorExport') // 高级关联导出
}
